package b.b.h;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.view.View;
import b.i.k.o;
import java.util.WeakHashMap;

/* compiled from: AppCompatBackgroundHelper */
public class c {
    public final View a;
    public final e b;
    public int c = -1;
    public d0 d;
    public d0 e;
    public d0 f;

    public c(View view) {
        this.a = view;
        this.b = e.a();
    }

    public void a() {
        Drawable background = this.a.getBackground();
        if (background != null) {
            d0 d0Var;
            int i = VERSION.SDK_INT;
            boolean z = true;
            Object obj = (i <= 21 ? i != 21 : this.d == null) ? null : 1;
            if (obj != null) {
                if (this.f == null) {
                    this.f = new d0();
                }
                d0Var = this.f;
                d0Var.a = null;
                d0Var.d = false;
                d0Var.b = null;
                d0Var.c = false;
                View view = this.a;
                WeakHashMap weakHashMap = o.a;
                ColorStateList backgroundTintList = view.getBackgroundTintList();
                if (backgroundTintList != null) {
                    d0Var.d = true;
                    d0Var.a = backgroundTintList;
                }
                Mode backgroundTintMode = this.a.getBackgroundTintMode();
                if (backgroundTintMode != null) {
                    d0Var.c = true;
                    d0Var.b = backgroundTintMode;
                }
                if (d0Var.d || d0Var.c) {
                    e.f(background, d0Var, this.a.getDrawableState());
                } else {
                    z = false;
                }
                if (z) {
                    return;
                }
            }
            d0Var = this.e;
            if (d0Var != null) {
                e.f(background, d0Var, this.a.getDrawableState());
            } else {
                d0Var = this.d;
                if (d0Var != null) {
                    e.f(background, d0Var, this.a.getDrawableState());
                }
            }
        }
    }

    public ColorStateList b() {
        d0 d0Var = this.e;
        return d0Var != null ? d0Var.a : null;
    }

    public Mode c() {
        d0 d0Var = this.e;
        return d0Var != null ? d0Var.b : null;
    }

    /* JADX WARNING: Removed duplicated region for block: B:22:0x006f A:{Catch:{ all -> 0x0077 }} */
    public void d(android.util.AttributeSet r11, int r12) {
        /*
        r10 = this;
        r0 = android.os.Build.VERSION.SDK_INT;
        r1 = r10.a;
        r1 = r1.getContext();
        r4 = b.b.b.z;
        r9 = 0;
        r1 = b.b.h.f0.q(r1, r11, r4, r12, r9);
        r2 = r10.a;
        r3 = r2.getContext();
        r6 = r1.b;
        r8 = 0;
        r5 = r11;
        r7 = r12;
        b.i.k.o.o(r2, r3, r4, r5, r6, r7, r8);
        r11 = r1.o(r9);	 Catch:{ all -> 0x0077 }
        r12 = -1;
        if (r11 == 0) goto L_0x003d;
    L_0x0024:
        r11 = r1.l(r9, r12);	 Catch:{ all -> 0x0077 }
        r10.c = r11;	 Catch:{ all -> 0x0077 }
        r11 = r10.b;	 Catch:{ all -> 0x0077 }
        r2 = r10.a;	 Catch:{ all -> 0x0077 }
        r2 = r2.getContext();	 Catch:{ all -> 0x0077 }
        r3 = r10.c;	 Catch:{ all -> 0x0077 }
        r11 = r11.d(r2, r3);	 Catch:{ all -> 0x0077 }
        if (r11 == 0) goto L_0x003d;
    L_0x003a:
        r10.g(r11);	 Catch:{ all -> 0x0077 }
    L_0x003d:
        r11 = 1;
        r2 = r1.o(r11);	 Catch:{ all -> 0x0077 }
        r3 = 21;
        if (r2 == 0) goto L_0x007c;
    L_0x0046:
        r2 = r10.a;	 Catch:{ all -> 0x0077 }
        r4 = r1.c(r11);	 Catch:{ all -> 0x0077 }
        r2.setBackgroundTintList(r4);	 Catch:{ all -> 0x0077 }
        if (r0 != r3) goto L_0x007c;
    L_0x0051:
        r4 = r2.getBackground();	 Catch:{ all -> 0x0077 }
        r5 = r2.getBackgroundTintList();	 Catch:{ all -> 0x0077 }
        if (r5 != 0) goto L_0x0064;
    L_0x005b:
        r5 = r2.getBackgroundTintMode();	 Catch:{ all -> 0x0077 }
        if (r5 == 0) goto L_0x0062;
    L_0x0061:
        goto L_0x0064;
    L_0x0062:
        r5 = 0;
        goto L_0x0065;
    L_0x0064:
        r5 = 1;
    L_0x0065:
        if (r4 == 0) goto L_0x007c;
    L_0x0067:
        if (r5 == 0) goto L_0x007c;
    L_0x0069:
        r5 = r4.isStateful();	 Catch:{ all -> 0x0077 }
        if (r5 == 0) goto L_0x0079;
    L_0x006f:
        r5 = r2.getDrawableState();	 Catch:{ all -> 0x0077 }
        r4.setState(r5);	 Catch:{ all -> 0x0077 }
        goto L_0x0079;
    L_0x0077:
        r11 = move-exception;
        goto L_0x00be;
    L_0x0079:
        r2.setBackground(r4);	 Catch:{ all -> 0x0077 }
    L_0x007c:
        r2 = 2;
        r4 = r1.o(r2);	 Catch:{ all -> 0x0077 }
        if (r4 == 0) goto L_0x00b8;
    L_0x0083:
        r4 = r10.a;	 Catch:{ all -> 0x0077 }
        r12 = r1.j(r2, r12);	 Catch:{ all -> 0x0077 }
        r2 = 0;
        r12 = b.b.h.o.c(r12, r2);	 Catch:{ all -> 0x0077 }
        r4.setBackgroundTintMode(r12);	 Catch:{ all -> 0x0077 }
        if (r0 != r3) goto L_0x00b8;
    L_0x0093:
        r12 = r4.getBackground();	 Catch:{ all -> 0x0077 }
        r0 = r4.getBackgroundTintList();	 Catch:{ all -> 0x0077 }
        if (r0 != 0) goto L_0x00a3;
    L_0x009d:
        r0 = r4.getBackgroundTintMode();	 Catch:{ all -> 0x0077 }
        if (r0 == 0) goto L_0x00a4;
    L_0x00a3:
        r9 = 1;
    L_0x00a4:
        if (r12 == 0) goto L_0x00b8;
    L_0x00a6:
        if (r9 == 0) goto L_0x00b8;
    L_0x00a8:
        r11 = r12.isStateful();	 Catch:{ all -> 0x0077 }
        if (r11 == 0) goto L_0x00b5;
    L_0x00ae:
        r11 = r4.getDrawableState();	 Catch:{ all -> 0x0077 }
        r12.setState(r11);	 Catch:{ all -> 0x0077 }
    L_0x00b5:
        r4.setBackground(r12);	 Catch:{ all -> 0x0077 }
    L_0x00b8:
        r11 = r1.b;
        r11.recycle();
        return;
    L_0x00be:
        r12 = r1.b;
        r12.recycle();
        throw r11;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.b.h.c.d(android.util.AttributeSet, int):void");
    }

    public void e() {
        this.c = -1;
        g(null);
        a();
    }

    public void f(int i) {
        this.c = i;
        e eVar = this.b;
        g(eVar != null ? eVar.d(this.a.getContext(), i) : null);
        a();
    }

    public void g(ColorStateList colorStateList) {
        if (colorStateList != null) {
            if (this.d == null) {
                this.d = new d0();
            }
            d0 d0Var = this.d;
            d0Var.a = colorStateList;
            d0Var.d = true;
        } else {
            this.d = null;
        }
        a();
    }

    public void h(ColorStateList colorStateList) {
        if (this.e == null) {
            this.e = new d0();
        }
        d0 d0Var = this.e;
        d0Var.a = colorStateList;
        d0Var.d = true;
        a();
    }

    public void i(Mode mode) {
        if (this.e == null) {
            this.e = new d0();
        }
        d0 d0Var = this.e;
        d0Var.b = mode;
        d0Var.c = true;
        a();
    }
}
